<style type="text/css">
    div.container {
        padding: .8em;
        margin-bottom: 1em;
        border-top: 1px solid #ddd;
        border-bottom: 1px solid #ddd;
        background: #FBE3E4;
        color: #8a1f11;
    }
    .hide { display: none; }
    h2.icon {
        height: 40px; line-height: 40px; font: 2.2em Georgia,serif;
        padding: 0; margin: 10px 0; color: #428a0a;
        background: url(<?php Yii::app()->baseUrl; ?>/assets/backend/images/mover.gif) no-repeat left 50%; padding-left: 50px;
    }

    div.tips {
        padding: .8em;
        margin-bottom: 1em;
        border-top: 1px solid #ddd;
        border-bottom: 1px solid #ddd;
        background: #FBE3E4;
        color: #8a1f11;
    }
    div.tips h2 {
        background: url(images/warning.gif) no-repeat left 50%; padding-left: 30px;
    }
</style>
<h2 class="icon">Hi, Can i help you?</h2>
<div class="container">
    <?php
    echo CHtml::beginForm();
    $cache_key = 'cache_item_nodes_tree_for_datas_transfer';
    $has_cache = Yii::app()->cache->get($cache_key);
    if ($has_cache === false) {
        require_once(Yii::app()->basePath . '/extensions/YHelper/YTreeFormat.php');
        //Yii::import('application.extensions.GraphTree.tree');
        $datas = Node::model()->getCTreeViewDatas();
        if (count($datas)) {
            $datas = dumpArrayTree($datas);
        }
        if (count($datas)) {
            foreach ($datas as $data) {
                $trees[$data['id']] = $data['levelstr'] . '⇒ ' . strip_tags($data['text']) . '《' . (string)$data['order_pos'] . '》';
            }
        } else {
            $trees = array();
        }
        Yii::app()->cache->set($cache_key, $trees, 300);
    } else {
        $trees = Yii::app()->cache->get($cache_key);
    }
    echo Yii::t('utils', 'datas_transfer_source_object');
    echo CHtml::dropDownList('source_object', 0, $trees);
    echo "&nbsp;&nbsp;&raquo;&raquo;&raquo;&nbsp;&nbsp;";
    echo Yii::t('utils', 'datas_transfer_target_object');
    echo CHtml::dropDownList('target_object', 0, $trees);
    echo CHtml::ajaxSubmitButton(Yii::t('utils', 'datas_transfer_begin'), array('utils/datasTransfer'), array(
            'type' => 'GET',
            'url' => array('showCategoryMediaList'),
            'update' => '#tip_msg',
            'beforeSend' => 'function() { $("#tip_msg").addClass("datasLoading").removeClass("hide"); }',
            'complete' => 'function() { $("#tip_msg").removeClass("datasLoading").addClass("tips"); }',
        ), array('class' => 'btn'));
    echo CHtml::endForm();
    ?>
</div>
<div id="tip_msg" class="hide"></div>
